/**
 * 
 */
package metagrammar;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

import com.google.common.collect.ImmutableList;

/**
 * @author Joshua Lockerman
 *
 */
public class OperatorTest {
    
    /**
     * Test method for {@link metagrammar.Operator#Operator(metagrammar.Type)}.
     */
    @Test
    public void testOperatorType()
    {
        assertNotNull(new Operator(Type.ROOT));
    }
    
    /**
     * Test method for {@link metagrammar.Operator#getInstance()}.
     */
    @Test
    public void testGetInstance()
    {
        assertNotNull(new Operator(Type.ROOT).getInstance());
    }
    
    /**
     * Test method for {@link metagrammar.Operator#takesInput()}.
     */
    @Test
    public void testTakesInput()
    {
        assertFalse(new Operator(Type.ROOT).takesInput());
        assertTrue(new Operator(Type.ROOT, new Type[] { Type.ROOT }).takesInput());
    }
    
    /**
     * Test method for {@link metagrammar.Operator#getInputTypes()}.
     */
    @Test
    public void testGetInputTypes()
    {
        Operator operator = new Operator(Type.ROOT, new Type[] { Type.ROOT, Type.UNTYPED });
        ImmutableList<Type> types = operator.getInputTypes();
        assertEquals(Type.ROOT, types.get(0));
        assertEquals(Type.UNTYPED, types.get(1));
    }
    
    /**
     * Test method for {@link metagrammar.Operator#getExpressedType()}.
     */
    @Test
    public void testGetExpressedType()
    {
        Operator operator = new Operator(Type.ROOT);
        assertEquals(Type.ROOT, operator.getExpressedType());
        assertFalse(operator.getType().equals(Type.UNTYPED));
    }
    
    /**
     * Test method for {@link metagrammar.Operator#getType()}.
     */
    @Test
    public void testGetType()
    {
        Operator operator = new Operator(Type.ROOT);
        assertSame(operator.getExpressedType(), operator.getType());
    }
    
}
